#!/usr/bin/Rscript
# _*_ coding: utf-8 _*_

library(CMplot)

args <- commandArgs()

pos_file_path=args[6]

karyotype <- data.frame(
    SNP=c("chr1", "chr2", "chr3", "chr4", "chr5", "chr6", "chr7", "chr8", "chr9", "chr10"),
    Chr=c(1,2,3,4,5,6,7,8,9,10),
    Pos=c(308452471, 243675191, 238017767, 250330460, 226353449, 181357234, 185808916, 182411202, 163004744, 152435371)
)

snp = read.table(
    pos_file_path,
    header = T
)

all_pos <- rbind(snp, karyotype)

CMplot(
    all_pos, plot.type="d", bin.size=1e6, chr.pos.max=TRUE,
    chr.den.col=c("darkgreen", "yellow", "red"),
    # file="png" # 背景透明
    file="jpg", file.name="density.plot", dpi=300,
    main="", # title
    file.output=TRUE, verbose=TRUE, width=16, height=8
)
